<script setup>
// 创建语音合成实例
let synth = window.speechSynthesis;

// 定义发音请求
let utterThis = new SpeechSynthesisUtterance('支付宝到账7.5元');
utterThis.lang = 'zh-CN';
utterThis.pitch = 1;
utterThis.rate = 1;
utterThis.volume = 1;

// 设置发音结束和开始的回调函数
utterThis.onend = function() {
console.log('语音播放结束');
};
utterThis.onstart = function() {
console.log('语音开始播放');
};

// 播放语音
const onPlay = ()=>{
    synth.speak(utterThis);
}
</script>

<template>
    <div class="demo-page">
        <h1>语音播放测试</h1>
        <button @click="onPlay">播放</button>
    </div>
</template>

<style scoped>

</style>